﻿using System.Data.Linq.Mapping;
using System.ComponentModel;

namespace DBHelper.DB
{
    [Table]
    public class SettingTable:INotifyPropertyChanged,INotifyPropertyChanging
    {

        private int settingid;

        [Column(IsPrimaryKey = true, IsDbGenerated = true, DbType = "INT NOT NULL Identity", CanBeNull = false, AutoSync = AutoSync.OnInsert)]
        public int SettingID
        {
            get
            {
                return settingid;
            }
            set
            {
                if (settingid != value)
                {
                    NotifyPropertyChanging("SettingID");
                    settingid = value;
                    NotifyPropertyChanged("SettingID");
                }
            }
        }

        private string settingname;

        [Column]
        public string SettingName
        {
            get
            {
                return settingname;
            }
            set
            {
                if (settingname != value)
                {
                    NotifyPropertyChanging("SettingName");
                    settingname = value;
                    NotifyPropertyChanged("SettingName");
                }
            }
        }

        private string settingvalue;

        [Column]
        public string SettingValue
        {
            get
            {
                return settingvalue;
            }
            set
            {
                if (settingvalue != value)
                {
                    NotifyPropertyChanging("SettingValue");
                    settingvalue = value;
                    NotifyPropertyChanged("SettingValue");
                }
            }
        }

        #region INotifyPropertyChanged 成员

        public event PropertyChangedEventHandler PropertyChanged;

        private void NotifyPropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }

        #endregion

        #region INotifyPropertyChanging 成员

        public event PropertyChangingEventHandler PropertyChanging;

        private void NotifyPropertyChanging(string propertyName)
        {
            if (PropertyChanging != null)
            {
                PropertyChanging(this, new PropertyChangingEventArgs(propertyName));
            }
        }

        #endregion
    }
}
